package org.mango.kryo.coder;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import org.mango.common.Message;
import org.mango.kryo.serializer.KryoSerializer;

/**
 * Created by meigang on 2019/8/8.
 */
public class KryoEncoder extends MessageToByteEncoder<Message> {
    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, Message message, ByteBuf byteBuf) throws Exception {
        KryoSerializer.serialize(message, byteBuf);
        channelHandlerContext.flush();
    }
}
